package com.ww.springboot.boot.test;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ww.springboot.boot.utils.Func;

import java.util.*;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2024-07-16 10:04
 */
public class CombineSkuCommon {

    private static int i = 0;


    public static void main(String[] args) throws Exception {

        String url = "https://service.izehui.com/api/cpms/sku/pageCombineSku";

        String bladeAuth = "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wYW55X2lkIjoiNzYzIiwicGFzc3dvcmRfZXhwaXJlZCI6ZmFsc2UsInVzZXJfbmFtZSI6IuS4h-S8nzA1MTYyIiwicmVhbF9uYW1lIjoi5LiH5LyfMDUxNjIiLCJhdmF0YXIiOiIiLCJsb2dpbl9tb2RlIjoiUEFTU1dPUkQiLCJhdXRob3JpdGllcyI6WyIxNDAyMTkxMDE2NTUzNTUzOTIyIiwiMTUyNDIxNzEyOTAxMTYyMTg4OSIsIjEzMjIzNzkwMTA2NjI4MDk2MDEiLCIxNDAyMTk0NjEyMTU4NDA2NjU3IiwiMTUwMTA4MDk0Nzg3NzU0MzkzNyIsIjE0NTgyNjk1NjkwNDEyMTk1ODYiXSwiY2xpZW50X2lkIjoic2FiZXIiLCJyb2xlX25hbWUiOiJhZG1pbixwbXMtYWRtaW4sZGV2ZWxvcGVyLGNvbW1vbl9sbXNfZ3JvdXAsYnVsbGZyb2dfZXJzLGltc19zZWFyY2giLCJsaWNlbnNlIjoicG93ZXJlZCBieSB6aGtqIiwicG9zdF9pZCI6IjEzOTA4ODc2Mjc5MjQ4ODk2MDIiLCJ1c2VyX2lkIjoiNTQ2MSIsInJvbGVfaWQiOiIxMzIyMzc5MDEwNjYyODA5NjAxLDE0NTgyNjk1NjkwNDEyMTk1ODYsMTQwMjE5MTAxNjU1MzU1MzkyMiwxNDAyMTk0NjEyMTU4NDA2NjU3LDE1MDEwODA5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ZZSA9,ZV5ZZT9H,ZTYQDC33,ZTQN2GKK,ZTQVWN2K,ZTQVWP1S,ZTQVWP1V,ZTQVWN2J,ZTQXB0FC,ZV5AXJ42,ZV4EEGST,SX8401527D2,ZV47K49H,ZTJMCJKS,ZV0HEHS1,TDXB2064Ax4,ZTAX9M51,ST62B560r33,T96JW195AX2,T96JW195BX2,T96JW195CX2,T96JX195WX2,T8GDC8256C3,ZTXS4E7H,ZTXS4D8A,ZTXS4E7M,ZTVZQC39,SZZAC872Ex4,SZZAC872Fx4,SZZAC872Gx4,ZTR1JHCP,ZTAVSVTS,T915R1467x2,ZV65E1FT,ZV65EB89,ZV65EC7H,ZV65EA91";

        List<String> skus = Func.toStrList(code);

        for (String sku : skus) {
            String body = "{\n" +
                    "    \"current\": 1,\n" +
                    "    \"size\": 10,\n" +
                    "    \"productSku\": \"" + sku + "\"\n" +
                    "}";

            String resp = HttpRequest.post(url)
                    .header("blade-auth", bladeAuth)
                    .body(body)
                    .execute()
                    .body();
            JSONObject jsonObject = JSON.parseObject(resp);
            JSONObject jsonObject1 = jsonObject.getJSONObject("data");
            JSONArray jsonArray = jsonObject1.getJSONArray("records");
            if (jsonArray.size() == 0) {
                continue;
            }
            JSONObject o = (JSONObject) jsonArray.get(0);
            String purchasePrice = o.getString("purchasePrice");
            String productSku = o.getString("productSku");
            String nwSku = o.getString("nwSku");
            String packWeight = o.getString("packWeight");
            System.out.println(productSku + "\t" + nwSku + "\t" + packWeight + "\t" + purchasePrice);
        }

    }


}
